import { Component, OnInit } from '@angular/core';
import { DataDetailService } from 'src/app/service/datadetai.service';

@Component({
    selector: 'app-data-detail',
    templateUrl: './data-detail.component.html',
    styleUrls: ['./data-detail.component.scss'],
})
export class DataDetailComponent implements OnInit {
    data: any[];
    constructor(private dataDetaiService: DataDetailService) {}
    searchForm = {
        meterId: '',
        wellName: '',
        applicantName: '',
    };
    reset = () => {
        this.searchForm.meterId = '';
        this.searchForm.wellName = '';
        this.searchForm.applicantName = '';
        this.search();
    };
    async search() {
        const res = await this.dataDetaiService.fetchDataDetailByConfig({
            applicantName: this.searchForm.applicantName || undefined,
            meterId: this.searchForm.meterId || undefined,
            wellName: this.searchForm.wellName || undefined,
        });
        console.log(res);
        if (res) {
            this.data = res;
            // .addAttrToEach('volume', floatGeneratorFactory('1000', '10000'))
            // .addAttrToEach('time', datetimeGenerator)
        }
    }
    ngOnInit(): void {
        this.search();
    }
}
